package com.roan.alipay.controller;

import com.alipay.api.response.AlipayTradeCloseResponse;
import com.alipay.api.response.AlipayTradePagePayResponse;
import com.roan.alipay.service.AlipayService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Roan
 * @date 2025/4/26 0:14
 */
@Slf4j
@RestController
@RequestMapping("/alipay")
public class AlipayController {

   @Autowired
   private AlipayService alipayService;

   @PostMapping("/init/{productId}")
   public AlipayTradePagePayResponse initPayment(@PathVariable("productId") String productId){
      return alipayService.pay(productId);
   }

   @PostMapping("/{transactionId}")
   public AlipayTradeCloseResponse query(@PathVariable("transactionId") String transactionId){
      return alipayService.query(transactionId);
   }

}
